<?php

// use Illuminate\Support\Facades\Schema;
use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitTopic extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('topics', function (Blueprint $table) {
            $table->comment = '论坛动态表';

            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->integer('user_id')->nullable()->index()->comment('用户id');

            $table->integer('parent_id')->nullable()->index()->comment('父id');

            $table->integer('group_id')->nullable()->index()->comment('topic_group id');
            $table->integer('tag_id')->nullable()->index()->comment('topic_tag id');

            $table->string('title')->nullable()->comment('标题');
            $table->text('text')->nullable()->comment('文本');
            $table->text('images')->nullable()->comment('图片');
            $table->text('videos')->nullable()->comment('视频');

            $table->integer('visit_total')->default(1)->index()->comment('访问数量');

            $table->integer('list_weight')->default(100)->index()->comment('列表权重');
            $table->tinyInteger('status')->default(1)->index()->comment('0为未上架 1为已上架 '); // 0为未上架 1为已上架 

            $table->softDeletes();
            $table->timestamps();
            
        });

        Schema::create('topic_groups', function (Blueprint $table) {
            $table->comment = '论坛圈子表';

            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->string('title')->nullable()->comment('标题');
            $table->string('thumb')->nullable()->comment('封面');

            $table->integer('list_weight')->default(100)->index()->comment('列表权重');
            $table->tinyInteger('status')->default(1)->index()->comment('0为未上架 1为已上架 '); // 0为未上架 1为已上架 

            $table->softDeletes();
            $table->timestamps();
        });

        Schema::create('topic_tags', function (Blueprint $table) {
            $table->comment = '论坛话题表';

            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->string('title')->nullable()->comment('标题');
            $table->string('thumb')->nullable()->comment('封面');

            $table->integer('list_weight')->default(100)->index()->comment('列表权重');
            $table->tinyInteger('status')->default(1)->index()->comment('0为未上架 1为已上架 '); // 0为未上架 1为已上架 

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('topics');
        Schema::dropIfExists('topic_groups');
        Schema::dropIfExists('topic_tags');
    }
}
